#ifndef SPECIESFACTORY_H
#define SPECIESFACTORY_H

#include "../Species/Species.h"
#include "Species1D.h"
#include "../Species/Species2D.h"
#include "Species3D.h"

#include "../Input/PicParams.h"
#include "../Parallel/ParallelMPI.h"

#include "../Tool/Macros.h"

class SpeciesFactory {
public:
    static std::vector<Species*> createVector(PicParams* params_, ParallelMPI* pmpi_)
    {
        std::vector<Species*> vecSpecies;
        vecSpecies.resize(params_->species_param.size());

        for (int ispec=0 ; ispec<params_->species_param.size() ; ispec++)
        {
            if(params_->geometry == "1d3v")
            {
                //cout<<"species 1d begin"<<endl;
                vecSpecies[ispec] = new Species1D(params_, pmpi_, ispec);
            } 
            else if(params_->geometry == "2d3v")
            {
                vecSpecies[ispec] = new Species2D(params_, pmpi_, ispec);
            }
            else if(params_->geometry == "3d3v")
            {
                vecSpecies[ispec] = new Species3D(params_, pmpi_, ispec);
            }

            int particle_number = vecSpecies[ispec]->get_number_of_particles();
            int particle_number_tot;
            pmpi_->reduce_sum_int(&particle_number, &particle_number_tot, 1);
            log_info<<params_->species_param[ispec].species_name<<" particle number: "<<particle_number_tot;
        } 

        return vecSpecies;
    }

};

#endif
